Repository navigation
fix(inference): the CPU generation fallback streams, samples and reports failure - #795
Merged
Merged
Conversation
…rts failure generate_streaming hands a request to the CPU Q4K path when the backend has no fused Q4 pipeline (the CPU backend, and per-layer-embedding models without the Metal PLE switch). It passed neither the token callback nor the sampling settings: a stream delivered nothing until generation finished, and every request was decoded greedily whatever temperature, top-p or seed it asked for. A decode step that produced nothing ended the loop and the truncated output was reported as success. The CPU path now takes the callback and the sampling settings. A greedy request keeps the KV-cached loops and calls back per token; a sampled one runs the sampling-aware CPU decoder with no mask. A step that produces nothing sets the result's error and keeps the tokens produced.
With the CPU generation fallback now calling the token callback, tokens that decode to no text (a special token, half of a multi-byte character) reached the OpenAI routes, and the responses stream sent an output_text.delta event with an empty delta for each. The token tap now buffers such a token and emits nothing for it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CPU generation fallback streams, samples and reports failure
What was wrong
generate_streaminghands a request to the CPU Q4K path when the backend has no fused Q4 pipeline: the CPU backend, and per-layer-embedding models (Gemma 4 E2B) unlessLARQL_METAL_PLE=1. The hand-off passed six arguments and dropped two:Inside the CPU loops, a decode step that produced nothing did
break, and the result was returned witherror: None: a truncated generation reported as a success.What changes
generate_via_cpu_q4ktakes the sampling settings and the callback.generate_constrained_via_cpu_q4k_streaming_sampled) with a mask that changes nothing.GenerateError::Other, naming the step and how many tokens preceded it) and keeps the tokens already produced.Evidence
Two tests through the public
generate_streamingwithCpuBackendon the Q4K fixture:df20de1e)Four more tests on the CPU path directly cover the greedy and sampled callbacks and seed determinism. Full
larql-inferencesuite: 1,978 passed, 0 failed.cargo fmt --check,cargo clippy -p larql-inference --lib --tests --benches --no-deps -D warningsandcargo check -p larql-server -p larql-cli --lib --bins --testsare clean.Server: no delta event for an empty token
With the callback firing, tokens that decode to no text (a special token, or the first half of a multi-byte character) reached the OpenAI routes, and the responses stream sent an
output_text.deltawith an empty delta for each. CI caught it inresponses_streaming_emits_typed_events_and_done. The second commit makes the server's token tap buffer such a token and emit nothing for it. Fulllarql-serversuite with it: 1,324 passed, 0 failed.Costs and limits